local js_lianzhu = fk.CreateSkill {
  name = "js__lianzhu",
}

js_lianzhu:addEffect("active", {
  anim_type = "control",
  card_num = 1,
  target_num = 1,
  prompt = "#js__lianzhu",
  can_use = function(self, player)
    return player:usedSkillTimes(self.name, Player.HistoryPhase) == 0
  end,
  card_filter =function (self, player, to_select, selected)
    return #selected == 0 and Fk:getCardById(to_select).color == Card.Black and table.contains(player:getCardIds("h"), to_select)
  end,
  target_filter =function (self, player, to_select, selected, selected_cards, card, extra_data)
    return #selected == 0 and to_select ~= player
  end,
  on_use = function(self, room, effect)
    local player = effect.from
    local target = effect.tos[1]
    player:showCards(effect.cards)
    if player.dead or target.dead then return end
    if table.contains(player:getCardIds("h"), effect.cards[1]) then
      room:moveCardTo(effect.cards, Card.PlayerHand, target, fk.ReasonGive, self.name, nil, false, player)
    end
    for _, p in ipairs(room:getOtherPlayers(player)) do
      if p.kingdom == target.kingdom and not p:isAllNude() and not player.dead then
        room:useVirtualCard("dismantlement", nil, player, p, self.name)
      end
    end
  end,
})

return js_lianzhu